package project02.controller.mobile.login;

import java.util.logging.Logger;
import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import project02.dao.UserInfoDao;
import project02.model.UserInfo;

public class IndexController extends Controller {

    UserInfoDao dao = new UserInfoDao();

    @SuppressWarnings("unused")
    private static final Logger logger = Logger.getLogger(IndexController.class.getName());

    @Override
    public Navigation run() {

        String iModeId = "";
        iModeId = request.getHeader("x-dcmguid");

        if (iModeId == null) {
            return forward("index.jsp");
        }

        UserInfo user = new UserInfo();

        try {
            user = dao.findByimodeId(iModeId);
        } catch (Exception e) {
            return forward("index.jsp");
        }
        if (user == null) {
            return forward("index.jsp");
        }

        requestScope("userInfo", user);

        return forward("/mobile/index2.jsp");
    }
}
